#include "gpsapp.h"
#include "garminusb.h"
#include "gpsusbcommon.h"
+#include "../garmin_device_xml.h"
/* Constants from Garmin doc. */
static HANDLE *usb_handle = INVALID_HANDLE_VALUE;
static int usb_tx_packet_size ;
+static const gdx_info *gdx;
static int
gusb_win_close(gpsdevh *handle)
return usb_handle;
}
+
+static char ** get_garmin_mountpoints() {
+#define BUFSIZE 512
+ TCHAR szTemp[MAX_PATH];
+ char *p = szTemp;
+ char **dlist = xmalloc(0);
+ int i = 0;
+
+ fprintf(stderr, "eek!\n");
+ if (GetLogicalDriveStrings(BUFSIZE-1, szTemp))
+ {
+ while(*p) {
+ dlist = xrealloc(dlist, sizeof (*dlist ) * ++i);
+ // fprintf(stderr, "Found: %d, %s\n", i, p);
+ dlist[i-1] = xstrdup(p);
+ dlist[i] = NULL;
+ while (*p++);
+ }
+ }
+
+ return dlist;
+}
+
/*
* Main entry point from the upper layer. Walk the device tree, find our
* device, and light it up.
if (!SetupDiEnumDeviceInterfaces(hdevinfo, NULL,
(GUID *) &GARMIN_GUID,
req_unit_number, &devinterface)) {
+ // If there were zero matches, we may be trying to talk to a "GPX Mode" device.
+
+
+ char **dlist = get_garmin_mountpoints();
+ gdx = gdx_find_file(dlist);
+ if (gdx) return 1;
+
+
+ // Plan C.
GPS_Serial_Error("SetupDiEnumDeviceInterfaces");
- warning("Is the Garmin USB unit number %d powered up and connected?\nIs it really a USB unit? If it's serial, don't choose USB, choose serial.\nAre the Garmin USB drivers installed and functioning with other programs?\nIs it a storage based device like Nuvi, CO, or OR?\n If so, send GPX files to it, don't use this module.", un);
+ warning("Is the Garmin USB unit number %d powered up and connected?\nIs it really a USB unit? If it's serial, don't choose USB, choose serial.\nAre the Garmin USB drivers installed and functioning with other programs?\nIs it a storage based device like Nuvi, CO, or OR?\n If so, send GPX files to it, don't use this module.\n", un);
return 0;
}
/* We've matched. Now start the specific unit. */
if (!SetupDiEnumDeviceInterfaces(hdevinfo, NULL,
(GUID *) &GARMIN_GUID, match, &devinterface)) {
if (GetLastError() == ERROR_NO_MORE_ITEMS) {
+
break;
} else {
+
GPS_Serial_Error("SetupDiEnumDeviceInterfaces");
warning("Is the Garmin USB unit number %d powered up and connected?", un);
return 0;